package com.tangtang.core;

/**
 * Created by Administrator on 2014/3/31.
 */
public class ConvertUtil {


    /**
     * @param input
     * @param defaultVal
     * @return
     */
    public static int StrToInt(String input, int defaultVal) {
        if (input != null && input.length() > 0) {
            try {
                return Integer.parseInt(input);
            } catch (NumberFormatException ex) {
            }
        }
        return defaultVal;
    }

    /**
     * @param input
     * @param defaultVal
     * @return
     */
    public static long StrToLong(String input, long defaultVal) {
        if (input != null && input.length() > 0) {
            try {
                return Long.parseLong(input);
            } catch (NumberFormatException ex) {
            }
        }
        return defaultVal;
    }
}
